{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import sys\n",
    "\n",
    "from mootdx.utils.adjust import fq_factor\n",
    "sys.path.append(r\"../../../../\")\n",
    "import pandas as pd\n",
    "\n",
    "from python_quant.stock.mootdx import init_tdx,get_price_shareing_table_by_date_list_adj_price\n"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "连接mootdx\n",
    "如果出现 not enough values to unpack 异常，在terminal终端中使用 mootdx bestip命令将最优ip写入mootdx，再把Quotes.factory的bestip参数设置为False"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "outputs": [],
   "source": [
    "client, reader = init_tdx(\"C://mySpace//mysoftware//tdx\")"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "拿到某只股票某个时间段的k线数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "获取前复权k线数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "outputs": [
    {
     "data": {
      "text/plain": "            open  close  high   low        vol        amount        date  \\\ndate                                                                       \n2011-07-28 24.50  25.39 27.50 24.50  275481.00  712907392.00  2011-07-28   \n2011-07-29 24.77  25.90 26.24 24.77  151000.00  388814976.00  2011-07-29   \n2011-08-01 25.55  26.18 26.95 24.01  135423.00  348325408.00  2011-08-01   \n2011-08-02 25.78  26.47 27.45 25.50  143658.00  384144224.00  2011-08-02   \n2011-08-03 25.98  25.41 26.37 25.38   89036.00  229332704.00  2011-08-03   \n...          ...    ...   ...   ...        ...           ...         ...   \n2023-04-26  6.33   6.46  6.65  6.05 3218887.00 2041135104.00  2023-04-26   \n2023-04-27  6.39   6.27  6.80  6.11 3326848.00 2145476096.00  2023-04-27   \n2023-04-28  6.09   6.85  6.90  6.05 5761689.00 3877471488.00  2023-04-28   \n2023-05-04  6.96   6.62  7.15  6.35 5427421.00 3609042176.00  2023-05-04   \n2023-05-05  6.40   5.96  6.46  5.96 3899421.00 2409541888.00  2023-05-05   \n\n              code  \ndate                \n2011-07-28  002602  \n2011-07-29  002602  \n2011-08-01  002602  \n2011-08-02  002602  \n2011-08-03  002602  \n...            ...  \n2023-04-26  002602  \n2023-04-27  002602  \n2023-04-28  002602  \n2023-05-04  002602  \n2023-05-05  002602  \n\n[2390 rows x 8 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>open</th>\n      <th>close</th>\n      <th>high</th>\n      <th>low</th>\n      <th>vol</th>\n      <th>amount</th>\n      <th>date</th>\n      <th>code</th>\n    </tr>\n    <tr>\n      <th>date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2011-07-28</th>\n      <td>24.50</td>\n      <td>25.39</td>\n      <td>27.50</td>\n      <td>24.50</td>\n      <td>275481.00</td>\n      <td>712907392.00</td>\n      <td>2011-07-28</td>\n      <td>002602</td>\n    </tr>\n    <tr>\n      <th>2011-07-29</th>\n      <td>24.77</td>\n      <td>25.90</td>\n      <td>26.24</td>\n      <td>24.77</td>\n      <td>151000.00</td>\n      <td>388814976.00</td>\n      <td>2011-07-29</td>\n      <td>002602</td>\n    </tr>\n    <tr>\n      <th>2011-08-01</th>\n      <td>25.55</td>\n      <td>26.18</td>\n      <td>26.95</td>\n      <td>24.01</td>\n      <td>135423.00</td>\n      <td>348325408.00</td>\n      <td>2011-08-01</td>\n      <td>002602</td>\n    </tr>\n    <tr>\n      <th>2011-08-02</th>\n      <td>25.78</td>\n      <td>26.47</td>\n      <td>27.45</td>\n      <td>25.50</td>\n      <td>143658.00</td>\n      <td>384144224.00</td>\n      <td>2011-08-02</td>\n      <td>002602</td>\n    </tr>\n    <tr>\n      <th>2011-08-03</th>\n      <td>25.98</td>\n      <td>25.41</td>\n      <td>26.37</td>\n      <td>25.38</td>\n      <td>89036.00</td>\n      <td>229332704.00</td>\n      <td>2011-08-03</td>\n      <td>002602</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>2023-04-26</th>\n      <td>6.33</td>\n      <td>6.46</td>\n      <td>6.65</td>\n      <td>6.05</td>\n      <td>3218887.00</td>\n      <td>2041135104.00</td>\n      <td>2023-04-26</td>\n      <td>002602</td>\n    </tr>\n    <tr>\n      <th>2023-04-27</th>\n      <td>6.39</td>\n      <td>6.27</td>\n      <td>6.80</td>\n      <td>6.11</td>\n      <td>3326848.00</td>\n      <td>2145476096.00</td>\n      <td>2023-04-27</td>\n      <td>002602</td>\n    </tr>\n    <tr>\n      <th>2023-04-28</th>\n      <td>6.09</td>\n      <td>6.85</td>\n      <td>6.90</td>\n      <td>6.05</td>\n      <td>5761689.00</td>\n      <td>3877471488.00</td>\n      <td>2023-04-28</td>\n      <td>002602</td>\n    </tr>\n    <tr>\n      <th>2023-05-04</th>\n      <td>6.96</td>\n      <td>6.62</td>\n      <td>7.15</td>\n      <td>6.35</td>\n      <td>5427421.00</td>\n      <td>3609042176.00</td>\n      <td>2023-05-04</td>\n      <td>002602</td>\n    </tr>\n    <tr>\n      <th>2023-05-05</th>\n      <td>6.40</td>\n      <td>5.96</td>\n      <td>6.46</td>\n      <td>5.96</td>\n      <td>3899421.00</td>\n      <td>2409541888.00</td>\n      <td>2023-05-05</td>\n      <td>002602</td>\n    </tr>\n  </tbody>\n</table>\n<p>2390 rows × 8 columns</p>\n</div>"
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "symbol = \"002602\"\n",
    "klines = client.k(symbol=symbol, begin=\"1991-11-02\", end=\"2023-05-06\")\n",
    "klines"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "查询某只股票的历史分时成交"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "total_his_minutes_df = minutes(client, symbol, klines['date'], '%Y-%m-%d', '%Y%m%d')\n",
    "total_his_minutes_df"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "通过历史分时计算历史分价"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "price_shareing_table = minutes_to_price_shareing_table(total_his_minutes_df)\n",
    "price_shareing_table"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "通过日期列表的方式获取分价表"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "symbol = \"300098\"\n",
    "klines = client.k(symbol=symbol, begin=\"2022-04-22\", end=\"2023-02-14\")\n",
    "price_shareing_table = get_price_shareing_table_by_date_list(client, symbol, klines['date'], '%Y-%m-%d', '%Y%m%d')\n",
    "price_shareing_table.head(100)"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "获取股票复权因子"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "fac = fq_factor('qfq','sz000732')\n",
    "fac"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "计算某个日期的复权因子"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "fac_fac = fac[fac['date']<='2018-01-24'].head(1)\n",
    "fac_fac"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "获取k线数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "symbol = \"601360\"\n",
    "klines = client.k(symbol=symbol, begin=\"1991-06-22\", end=\"2023-02-09\")\n",
    "klines"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "k线复权"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "def fac_compute(x):\n",
    "    factor = fac_df[fac_df['date'] <= x['date']].head(1)\n",
    "    return float(factor['qfq_factor'])\n",
    "\n",
    "fac_df = fq_factor('qfq_factor',code_to_sz_sh_symbol(symbol))\n",
    "klines['factor'] = klines.apply(fac_compute, axis=1)\n",
    "klines['adj_close'] = round(klines['close']/klines['factor'],2)\n",
    "\n",
    "klines"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "获取复权分时成交数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "total_his_minutes_df = minutes_adj(client, symbol, klines['date'], '%Y-%m-%d', '%Y%m%d','qfq_factor')\n",
    "total_his_minutes_df"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "按价格分组成交金额求和"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "sum_df = total_his_minutes_df.groupby(['fq_price'], as_index=False)['amounts'].sum()\n",
    "sum_df = sum_df.sort_values(by='amounts', ascending=[False])\n",
    "sum_df"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "价格复权后的成交金额排序"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "\n",
    "price_shareing_table = get_price_shareing_table_by_date_list_adj_price(client, symbol, klines['date'], '%Y-%m-%d', '%Y%m%d','qfq_factor')\n",
    "price_shareing_table = price_shareing_table.sort_values(by='fq_price', ascending=[False]).reset_index(drop=True)\n",
    "price_shareing_table"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "最大成交金额距离当前价，上方成交最大价，下方成交最大价的涨跌幅"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "outputs": [
    {
     "ename": "ConnectTimeout",
     "evalue": "_ssl.c:1114: The handshake operation timed out",
     "output_type": "error",
     "traceback": [
      "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[1;31mtimeout\u001B[0m                                   Traceback (most recent call last)",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpcore\\_exceptions.py:10\u001B[0m, in \u001B[0;36mmap_exceptions\u001B[1;34m(map)\u001B[0m\n\u001B[0;32m      9\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m---> 10\u001B[0m     \u001B[38;5;28;01myield\u001B[39;00m\n\u001B[0;32m     11\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mException\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m exc:  \u001B[38;5;66;03m# noqa: PIE786\u001B[39;00m\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpcore\\backends\\sync.py:62\u001B[0m, in \u001B[0;36mSyncStream.start_tls\u001B[1;34m(self, ssl_context, server_hostname, timeout)\u001B[0m\n\u001B[0;32m     61\u001B[0m         \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mclose()\n\u001B[1;32m---> 62\u001B[0m         \u001B[38;5;28;01mraise\u001B[39;00m exc\n\u001B[0;32m     63\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m SyncStream(sock)\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpcore\\backends\\sync.py:57\u001B[0m, in \u001B[0;36mSyncStream.start_tls\u001B[1;34m(self, ssl_context, server_hostname, timeout)\u001B[0m\n\u001B[0;32m     56\u001B[0m     \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_sock\u001B[38;5;241m.\u001B[39msettimeout(timeout)\n\u001B[1;32m---> 57\u001B[0m     sock \u001B[38;5;241m=\u001B[39m \u001B[43mssl_context\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mwrap_socket\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m     58\u001B[0m \u001B[43m        \u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_sock\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mserver_hostname\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mserver_hostname\u001B[49m\n\u001B[0;32m     59\u001B[0m \u001B[43m    \u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m     60\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mException\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m exc:  \u001B[38;5;66;03m# pragma: nocover\u001B[39;00m\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\ssl.py:500\u001B[0m, in \u001B[0;36mSSLContext.wrap_socket\u001B[1;34m(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)\u001B[0m\n\u001B[0;32m    494\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mwrap_socket\u001B[39m(\u001B[38;5;28mself\u001B[39m, sock, server_side\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mFalse\u001B[39;00m,\n\u001B[0;32m    495\u001B[0m                 do_handshake_on_connect\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m,\n\u001B[0;32m    496\u001B[0m                 suppress_ragged_eofs\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m,\n\u001B[0;32m    497\u001B[0m                 server_hostname\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m, session\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m):\n\u001B[0;32m    498\u001B[0m     \u001B[38;5;66;03m# SSLSocket class handles server_hostname encoding before it calls\u001B[39;00m\n\u001B[0;32m    499\u001B[0m     \u001B[38;5;66;03m# ctx._wrap_socket()\u001B[39;00m\n\u001B[1;32m--> 500\u001B[0m     \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43msslsocket_class\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_create\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m    501\u001B[0m \u001B[43m        \u001B[49m\u001B[43msock\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43msock\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m    502\u001B[0m \u001B[43m        \u001B[49m\u001B[43mserver_side\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mserver_side\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m    503\u001B[0m \u001B[43m        \u001B[49m\u001B[43mdo_handshake_on_connect\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mdo_handshake_on_connect\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m    504\u001B[0m \u001B[43m        \u001B[49m\u001B[43msuppress_ragged_eofs\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43msuppress_ragged_eofs\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m    505\u001B[0m \u001B[43m        \u001B[49m\u001B[43mserver_hostname\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mserver_hostname\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m    506\u001B[0m \u001B[43m        \u001B[49m\u001B[43mcontext\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[43m,\u001B[49m\n\u001B[0;32m    507\u001B[0m \u001B[43m        \u001B[49m\u001B[43msession\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43msession\u001B[49m\n\u001B[0;32m    508\u001B[0m \u001B[43m    \u001B[49m\u001B[43m)\u001B[49m\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\ssl.py:1040\u001B[0m, in \u001B[0;36mSSLSocket._create\u001B[1;34m(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)\u001B[0m\n\u001B[0;32m   1039\u001B[0m             \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mValueError\u001B[39;00m(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mdo_handshake_on_connect should not be specified for non-blocking sockets\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n\u001B[1;32m-> 1040\u001B[0m         \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mdo_handshake\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m   1041\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m (\u001B[38;5;167;01mOSError\u001B[39;00m, \u001B[38;5;167;01mValueError\u001B[39;00m):\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\ssl.py:1309\u001B[0m, in \u001B[0;36mSSLSocket.do_handshake\u001B[1;34m(self, block)\u001B[0m\n\u001B[0;32m   1308\u001B[0m         \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39msettimeout(\u001B[38;5;28;01mNone\u001B[39;00m)\n\u001B[1;32m-> 1309\u001B[0m     \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_sslobj\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mdo_handshake\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m   1310\u001B[0m \u001B[38;5;28;01mfinally\u001B[39;00m:\n",
      "\u001B[1;31mtimeout\u001B[0m: _ssl.c:1114: The handshake operation timed out",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001B[1;31mConnectTimeout\u001B[0m                            Traceback (most recent call last)",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpx\\_transports\\default.py:60\u001B[0m, in \u001B[0;36mmap_httpcore_exceptions\u001B[1;34m()\u001B[0m\n\u001B[0;32m     59\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m---> 60\u001B[0m     \u001B[38;5;28;01myield\u001B[39;00m\n\u001B[0;32m     61\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mException\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m exc:  \u001B[38;5;66;03m# noqa: PIE-786\u001B[39;00m\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpx\\_transports\\default.py:218\u001B[0m, in \u001B[0;36mHTTPTransport.handle_request\u001B[1;34m(self, request)\u001B[0m\n\u001B[0;32m    217\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m map_httpcore_exceptions():\n\u001B[1;32m--> 218\u001B[0m     resp \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_pool\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mhandle_request\u001B[49m\u001B[43m(\u001B[49m\u001B[43mreq\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    220\u001B[0m \u001B[38;5;28;01massert\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(resp\u001B[38;5;241m.\u001B[39mstream, typing\u001B[38;5;241m.\u001B[39mIterable)\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpcore\\_sync\\connection_pool.py:253\u001B[0m, in \u001B[0;36mConnectionPool.handle_request\u001B[1;34m(self, request)\u001B[0m\n\u001B[0;32m    252\u001B[0m     \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mresponse_closed(status)\n\u001B[1;32m--> 253\u001B[0m     \u001B[38;5;28;01mraise\u001B[39;00m exc\n\u001B[0;32m    254\u001B[0m \u001B[38;5;28;01melse\u001B[39;00m:\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpcore\\_sync\\connection_pool.py:237\u001B[0m, in \u001B[0;36mConnectionPool.handle_request\u001B[1;34m(self, request)\u001B[0m\n\u001B[0;32m    236\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 237\u001B[0m     response \u001B[38;5;241m=\u001B[39m \u001B[43mconnection\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mhandle_request\u001B[49m\u001B[43m(\u001B[49m\u001B[43mrequest\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    238\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m ConnectionNotAvailable:\n\u001B[0;32m    239\u001B[0m     \u001B[38;5;66;03m# The ConnectionNotAvailable exception is a special case, that\u001B[39;00m\n\u001B[0;32m    240\u001B[0m     \u001B[38;5;66;03m# indicates we need to retry the request on a new connection.\u001B[39;00m\n\u001B[1;32m   (...)\u001B[0m\n\u001B[0;32m    244\u001B[0m     \u001B[38;5;66;03m# might end up as an HTTP/2 connection, but which actually ends\u001B[39;00m\n\u001B[0;32m    245\u001B[0m     \u001B[38;5;66;03m# up as HTTP/1.1.\u001B[39;00m\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpcore\\_sync\\http_proxy.py:261\u001B[0m, in \u001B[0;36mTunnelHTTPConnection.handle_request\u001B[1;34m(self, request)\u001B[0m\n\u001B[0;32m    255\u001B[0m connect_request \u001B[38;5;241m=\u001B[39m Request(\n\u001B[0;32m    256\u001B[0m     method\u001B[38;5;241m=\u001B[39m\u001B[38;5;124mb\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mCONNECT\u001B[39m\u001B[38;5;124m\"\u001B[39m,\n\u001B[0;32m    257\u001B[0m     url\u001B[38;5;241m=\u001B[39mconnect_url,\n\u001B[0;32m    258\u001B[0m     headers\u001B[38;5;241m=\u001B[39mconnect_headers,\n\u001B[0;32m    259\u001B[0m     extensions\u001B[38;5;241m=\u001B[39mrequest\u001B[38;5;241m.\u001B[39mextensions,\n\u001B[0;32m    260\u001B[0m )\n\u001B[1;32m--> 261\u001B[0m connect_response \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_connection\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mhandle_request\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m    262\u001B[0m \u001B[43m    \u001B[49m\u001B[43mconnect_request\u001B[49m\n\u001B[0;32m    263\u001B[0m \u001B[43m\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    265\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m connect_response\u001B[38;5;241m.\u001B[39mstatus \u001B[38;5;241m<\u001B[39m \u001B[38;5;241m200\u001B[39m \u001B[38;5;129;01mor\u001B[39;00m connect_response\u001B[38;5;241m.\u001B[39mstatus \u001B[38;5;241m>\u001B[39m \u001B[38;5;241m299\u001B[39m:\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpcore\\_sync\\connection.py:86\u001B[0m, in \u001B[0;36mHTTPConnection.handle_request\u001B[1;34m(self, request)\u001B[0m\n\u001B[0;32m     85\u001B[0m         \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_connect_failed \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mTrue\u001B[39;00m\n\u001B[1;32m---> 86\u001B[0m         \u001B[38;5;28;01mraise\u001B[39;00m exc\n\u001B[0;32m     87\u001B[0m \u001B[38;5;28;01melif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_connection\u001B[38;5;241m.\u001B[39mis_available():\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpcore\\_sync\\connection.py:63\u001B[0m, in \u001B[0;36mHTTPConnection.handle_request\u001B[1;34m(self, request)\u001B[0m\n\u001B[0;32m     62\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m---> 63\u001B[0m     stream \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_connect\u001B[49m\u001B[43m(\u001B[49m\u001B[43mrequest\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m     65\u001B[0m     ssl_object \u001B[38;5;241m=\u001B[39m stream\u001B[38;5;241m.\u001B[39mget_extra_info(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mssl_object\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpcore\\_sync\\connection.py:150\u001B[0m, in \u001B[0;36mHTTPConnection._connect\u001B[1;34m(self, request)\u001B[0m\n\u001B[0;32m    149\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m Trace(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mconnection.start_tls\u001B[39m\u001B[38;5;124m\"\u001B[39m, request, kwargs) \u001B[38;5;28;01mas\u001B[39;00m trace:\n\u001B[1;32m--> 150\u001B[0m     stream \u001B[38;5;241m=\u001B[39m \u001B[43mstream\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mstart_tls\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mkwargs\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    151\u001B[0m     trace\u001B[38;5;241m.\u001B[39mreturn_value \u001B[38;5;241m=\u001B[39m stream\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpcore\\backends\\sync.py:62\u001B[0m, in \u001B[0;36mSyncStream.start_tls\u001B[1;34m(self, ssl_context, server_hostname, timeout)\u001B[0m\n\u001B[0;32m     61\u001B[0m         \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mclose()\n\u001B[1;32m---> 62\u001B[0m         \u001B[38;5;28;01mraise\u001B[39;00m exc\n\u001B[0;32m     63\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m SyncStream(sock)\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\contextlib.py:131\u001B[0m, in \u001B[0;36m_GeneratorContextManager.__exit__\u001B[1;34m(self, type, value, traceback)\u001B[0m\n\u001B[0;32m    130\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 131\u001B[0m     \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mgen\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mthrow\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;28;43mtype\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mvalue\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mtraceback\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    132\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mStopIteration\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m exc:\n\u001B[0;32m    133\u001B[0m     \u001B[38;5;66;03m# Suppress StopIteration *unless* it's the same exception that\u001B[39;00m\n\u001B[0;32m    134\u001B[0m     \u001B[38;5;66;03m# was passed to throw().  This prevents a StopIteration\u001B[39;00m\n\u001B[0;32m    135\u001B[0m     \u001B[38;5;66;03m# raised inside the \"with\" statement from being suppressed.\u001B[39;00m\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpcore\\_exceptions.py:14\u001B[0m, in \u001B[0;36mmap_exceptions\u001B[1;34m(map)\u001B[0m\n\u001B[0;32m     13\u001B[0m     \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(exc, from_exc):\n\u001B[1;32m---> 14\u001B[0m         \u001B[38;5;28;01mraise\u001B[39;00m to_exc(exc)\n\u001B[0;32m     15\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m\n",
      "\u001B[1;31mConnectTimeout\u001B[0m: _ssl.c:1114: The handshake operation timed out",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001B[1;31mConnectTimeout\u001B[0m                            Traceback (most recent call last)",
      "Cell \u001B[1;32mIn[23], line 4\u001B[0m\n\u001B[0;32m      2\u001B[0m klines \u001B[38;5;241m=\u001B[39m client\u001B[38;5;241m.\u001B[39mk(symbol\u001B[38;5;241m=\u001B[39msymbol, begin\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124m1991-01-01\u001B[39m\u001B[38;5;124m\"\u001B[39m, end\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124m2023-02-20\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n\u001B[0;32m      3\u001B[0m close_new \u001B[38;5;241m=\u001B[39m  klines[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mclose\u001B[39m\u001B[38;5;124m'\u001B[39m][\u001B[38;5;241m-\u001B[39m\u001B[38;5;241m1\u001B[39m]\n\u001B[1;32m----> 4\u001B[0m price_shareing_table \u001B[38;5;241m=\u001B[39m \u001B[43mget_price_shareing_table_by_date_list_adj_price\u001B[49m\u001B[43m(\u001B[49m\u001B[43mclient\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43msymbol\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mklines\u001B[49m\u001B[43m[\u001B[49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[38;5;124;43mdate\u001B[39;49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[43m]\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[38;5;124;43m%\u001B[39;49m\u001B[38;5;124;43mY-\u001B[39;49m\u001B[38;5;124;43m%\u001B[39;49m\u001B[38;5;124;43mm-\u001B[39;49m\u001B[38;5;132;43;01m%d\u001B[39;49;00m\u001B[38;5;124;43m'\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[38;5;124;43m%\u001B[39;49m\u001B[38;5;124;43mY\u001B[39;49m\u001B[38;5;124;43m%\u001B[39;49m\u001B[38;5;124;43mm\u001B[39;49m\u001B[38;5;132;43;01m%d\u001B[39;49;00m\u001B[38;5;124;43m'\u001B[39;49m\u001B[43m,\u001B[49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[38;5;124;43mqfq_factor\u001B[39;49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[43m)\u001B[49m\n\u001B[0;32m      5\u001B[0m price_shareing_table \u001B[38;5;241m=\u001B[39m price_shareing_table\u001B[38;5;241m.\u001B[39msort_values(by\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mfq_price\u001B[39m\u001B[38;5;124m'\u001B[39m, ascending\u001B[38;5;241m=\u001B[39m[\u001B[38;5;28;01mFalse\u001B[39;00m])\u001B[38;5;241m.\u001B[39mreset_index(drop\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m)\n\u001B[0;32m      6\u001B[0m down_max_table \u001B[38;5;241m=\u001B[39m price_shareing_table[close_new\u001B[38;5;241m>\u001B[39m\u001B[38;5;241m=\u001B[39mprice_shareing_table[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mfq_price\u001B[39m\u001B[38;5;124m'\u001B[39m]]\u001B[38;5;241m.\u001B[39msort_values(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mamounts\u001B[39m\u001B[38;5;124m'\u001B[39m,ascending\u001B[38;5;241m=\u001B[39m[\u001B[38;5;28;01mFalse\u001B[39;00m])\u001B[38;5;241m.\u001B[39mhead(\u001B[38;5;241m1\u001B[39m)\n",
      "File \u001B[1;32mC:\\mySpace\\DEVTEST\\stocksfuture\\jue_jin_strategy\\研究\\接口\\数据接口\\mootdx\\../../../..\\python_quant\\stock\\mootdx.py:44\u001B[0m, in \u001B[0;36mget_price_shareing_table_by_date_list_adj_price\u001B[1;34m(client, symbol, date_list, parttern_old, parttern_new, adj_way)\u001B[0m\n\u001B[0;32m     40\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mget_price_shareing_table_by_date_list_adj_price\u001B[39m(client, symbol, date_list, parttern_old, parttern_new, adj_way):\n\u001B[0;32m     41\u001B[0m     \u001B[38;5;124;03m\"\"\"\u001B[39;00m\n\u001B[0;32m     42\u001B[0m \u001B[38;5;124;03m    通过日期列表的方式获取分价表\u001B[39;00m\n\u001B[0;32m     43\u001B[0m \u001B[38;5;124;03m    \"\"\"\u001B[39;00m\n\u001B[1;32m---> 44\u001B[0m     total_minutes_df \u001B[38;5;241m=\u001B[39m \u001B[43mminutes_adj\u001B[49m\u001B[43m(\u001B[49m\u001B[43mclient\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43msymbol\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mdate_list\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mparttern_old\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mparttern_new\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43madj_way\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m     45\u001B[0m     \u001B[38;5;28;01mreturn\u001B[39;00m minutes_to_price_shareing_table_adj_price(total_minutes_df)\n",
      "File \u001B[1;32mC:\\mySpace\\DEVTEST\\stocksfuture\\jue_jin_strategy\\研究\\接口\\数据接口\\mootdx\\../../../..\\python_quant\\stock\\mootdx.py:66\u001B[0m, in \u001B[0;36mminutes_adj\u001B[1;34m(client, symbol, date_list, parttern_old, parttern_new, adj_way)\u001B[0m\n\u001B[0;32m     62\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mminutes_adj\u001B[39m(client, symbol, date_list, parttern_old, parttern_new, adj_way):\n\u001B[0;32m     63\u001B[0m     \u001B[38;5;124;03m\"\"\"\u001B[39;00m\n\u001B[0;32m     64\u001B[0m \u001B[38;5;124;03m    历史分时\u001B[39;00m\n\u001B[0;32m     65\u001B[0m \u001B[38;5;124;03m    \"\"\"\u001B[39;00m\n\u001B[1;32m---> 66\u001B[0m     fq_factors \u001B[38;5;241m=\u001B[39m \u001B[43mfq_factor\u001B[49m\u001B[43m(\u001B[49m\u001B[43madj_way\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mcode_to_sz_sh_symbol\u001B[49m\u001B[43m(\u001B[49m\u001B[43msymbol\u001B[49m\u001B[43m)\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m     67\u001B[0m     total_his_minutes_df \u001B[38;5;241m=\u001B[39m pd\u001B[38;5;241m.\u001B[39mDataFrame()\n\u001B[0;32m     68\u001B[0m     \u001B[38;5;28;01mfor\u001B[39;00m date \u001B[38;5;129;01min\u001B[39;00m date_list:\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\tenacity\\__init__.py:289\u001B[0m, in \u001B[0;36mBaseRetrying.wraps.<locals>.wrapped_f\u001B[1;34m(*args, **kw)\u001B[0m\n\u001B[0;32m    287\u001B[0m \u001B[38;5;129m@functools\u001B[39m\u001B[38;5;241m.\u001B[39mwraps(f)\n\u001B[0;32m    288\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mwrapped_f\u001B[39m(\u001B[38;5;241m*\u001B[39margs: t\u001B[38;5;241m.\u001B[39mAny, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkw: t\u001B[38;5;241m.\u001B[39mAny) \u001B[38;5;241m-\u001B[39m\u001B[38;5;241m>\u001B[39m t\u001B[38;5;241m.\u001B[39mAny:\n\u001B[1;32m--> 289\u001B[0m     \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[43m(\u001B[49m\u001B[43mf\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43margs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mkw\u001B[49m\u001B[43m)\u001B[49m\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\tenacity\\__init__.py:379\u001B[0m, in \u001B[0;36mRetrying.__call__\u001B[1;34m(self, fn, *args, **kwargs)\u001B[0m\n\u001B[0;32m    377\u001B[0m retry_state \u001B[38;5;241m=\u001B[39m RetryCallState(retry_object\u001B[38;5;241m=\u001B[39m\u001B[38;5;28mself\u001B[39m, fn\u001B[38;5;241m=\u001B[39mfn, args\u001B[38;5;241m=\u001B[39margs, kwargs\u001B[38;5;241m=\u001B[39mkwargs)\n\u001B[0;32m    378\u001B[0m \u001B[38;5;28;01mwhile\u001B[39;00m \u001B[38;5;28;01mTrue\u001B[39;00m:\n\u001B[1;32m--> 379\u001B[0m     do \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43miter\u001B[49m\u001B[43m(\u001B[49m\u001B[43mretry_state\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mretry_state\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    380\u001B[0m     \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(do, DoAttempt):\n\u001B[0;32m    381\u001B[0m         \u001B[38;5;28;01mtry\u001B[39;00m:\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\tenacity\\__init__.py:322\u001B[0m, in \u001B[0;36mBaseRetrying.iter\u001B[1;34m(self, retry_state)\u001B[0m\n\u001B[0;32m    320\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mstop(retry_state):\n\u001B[0;32m    321\u001B[0m     \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mretry_error_callback:\n\u001B[1;32m--> 322\u001B[0m         \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mretry_error_callback\u001B[49m\u001B[43m(\u001B[49m\u001B[43mretry_state\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    323\u001B[0m     retry_exc \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mretry_error_cls(fut)\n\u001B[0;32m    324\u001B[0m     \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mreraise:\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\mootdx\\consts.py:115\u001B[0m, in \u001B[0;36mreturn_last_value\u001B[1;34m(retry_state)\u001B[0m\n\u001B[0;32m    113\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mreturn_last_value\u001B[39m(retry_state):\n\u001B[0;32m    114\u001B[0m     \u001B[38;5;124;03m\"\"\"return the result of the last call attempt\"\"\"\u001B[39;00m\n\u001B[1;32m--> 115\u001B[0m     \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[43mretry_state\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43moutcome\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mresult\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\concurrent\\futures\\_base.py:437\u001B[0m, in \u001B[0;36mFuture.result\u001B[1;34m(self, timeout)\u001B[0m\n\u001B[0;32m    435\u001B[0m     \u001B[38;5;28;01mraise\u001B[39;00m CancelledError()\n\u001B[0;32m    436\u001B[0m \u001B[38;5;28;01melif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_state \u001B[38;5;241m==\u001B[39m FINISHED:\n\u001B[1;32m--> 437\u001B[0m     \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m__get_result\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    439\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_condition\u001B[38;5;241m.\u001B[39mwait(timeout)\n\u001B[0;32m    441\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_state \u001B[38;5;129;01min\u001B[39;00m [CANCELLED, CANCELLED_AND_NOTIFIED]:\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\concurrent\\futures\\_base.py:389\u001B[0m, in \u001B[0;36mFuture.__get_result\u001B[1;34m(self)\u001B[0m\n\u001B[0;32m    387\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_exception:\n\u001B[0;32m    388\u001B[0m     \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 389\u001B[0m         \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_exception\n\u001B[0;32m    390\u001B[0m     \u001B[38;5;28;01mfinally\u001B[39;00m:\n\u001B[0;32m    391\u001B[0m         \u001B[38;5;66;03m# Break a reference cycle with the exception in self._exception\u001B[39;00m\n\u001B[0;32m    392\u001B[0m         \u001B[38;5;28mself\u001B[39m \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mNone\u001B[39;00m\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\tenacity\\__init__.py:382\u001B[0m, in \u001B[0;36mRetrying.__call__\u001B[1;34m(self, fn, *args, **kwargs)\u001B[0m\n\u001B[0;32m    380\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(do, DoAttempt):\n\u001B[0;32m    381\u001B[0m     \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 382\u001B[0m         result \u001B[38;5;241m=\u001B[39m \u001B[43mfn\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43margs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mkwargs\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    383\u001B[0m     \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mBaseException\u001B[39;00m:  \u001B[38;5;66;03m# noqa: B902\u001B[39;00m\n\u001B[0;32m    384\u001B[0m         retry_state\u001B[38;5;241m.\u001B[39mset_exception(sys\u001B[38;5;241m.\u001B[39mexc_info())  \u001B[38;5;66;03m# type: ignore[arg-type]\u001B[39;00m\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\mootdx\\utils\\adjust.py:44\u001B[0m, in \u001B[0;36mfq_factor\u001B[1;34m(method, symbol)\u001B[0m\n\u001B[0;32m     42\u001B[0m     \u001B[38;5;28;01mreturn\u001B[39;00m hfq_factor_df\n\u001B[0;32m     43\u001B[0m \u001B[38;5;28;01melse\u001B[39;00m:\n\u001B[1;32m---> 44\u001B[0m     res \u001B[38;5;241m=\u001B[39m \u001B[43mclient\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mget\u001B[49m\u001B[43m(\u001B[49m\u001B[43mzh_sina_a_stock_qfq_url\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mformat\u001B[49m\u001B[43m(\u001B[49m\u001B[43msymbol\u001B[49m\u001B[43m)\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m     45\u001B[0m     qfq_factor_df \u001B[38;5;241m=\u001B[39m pd\u001B[38;5;241m.\u001B[39mDataFrame(json\u001B[38;5;241m.\u001B[39mloads(res\u001B[38;5;241m.\u001B[39mtext\u001B[38;5;241m.\u001B[39msplit(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124m=\u001B[39m\u001B[38;5;124m\"\u001B[39m)[\u001B[38;5;241m1\u001B[39m]\u001B[38;5;241m.\u001B[39msplit(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;130;01m\\n\u001B[39;00m\u001B[38;5;124m\"\u001B[39m)[\u001B[38;5;241m0\u001B[39m])[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mdata\u001B[39m\u001B[38;5;124m\"\u001B[39m])\n\u001B[0;32m     47\u001B[0m     \u001B[38;5;28;01mif\u001B[39;00m qfq_factor_df\u001B[38;5;241m.\u001B[39mshape[\u001B[38;5;241m0\u001B[39m] \u001B[38;5;241m==\u001B[39m \u001B[38;5;241m0\u001B[39m:\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpx\\_client.py:1045\u001B[0m, in \u001B[0;36mClient.get\u001B[1;34m(self, url, params, headers, cookies, auth, follow_redirects, timeout, extensions)\u001B[0m\n\u001B[0;32m   1028\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mget\u001B[39m(\n\u001B[0;32m   1029\u001B[0m     \u001B[38;5;28mself\u001B[39m,\n\u001B[0;32m   1030\u001B[0m     url: URLTypes,\n\u001B[1;32m   (...)\u001B[0m\n\u001B[0;32m   1038\u001B[0m     extensions: typing\u001B[38;5;241m.\u001B[39mOptional[RequestExtensions] \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mNone\u001B[39;00m,\n\u001B[0;32m   1039\u001B[0m ) \u001B[38;5;241m-\u001B[39m\u001B[38;5;241m>\u001B[39m Response:\n\u001B[0;32m   1040\u001B[0m     \u001B[38;5;124;03m\"\"\"\u001B[39;00m\n\u001B[0;32m   1041\u001B[0m \u001B[38;5;124;03m    Send a `GET` request.\u001B[39;00m\n\u001B[0;32m   1042\u001B[0m \n\u001B[0;32m   1043\u001B[0m \u001B[38;5;124;03m    **Parameters**: See `httpx.request`.\u001B[39;00m\n\u001B[0;32m   1044\u001B[0m \u001B[38;5;124;03m    \"\"\"\u001B[39;00m\n\u001B[1;32m-> 1045\u001B[0m     \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mrequest\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m   1046\u001B[0m \u001B[43m        \u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43mGET\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m,\u001B[49m\n\u001B[0;32m   1047\u001B[0m \u001B[43m        \u001B[49m\u001B[43murl\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m   1048\u001B[0m \u001B[43m        \u001B[49m\u001B[43mparams\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mparams\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m   1049\u001B[0m \u001B[43m        \u001B[49m\u001B[43mheaders\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mheaders\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m   1050\u001B[0m \u001B[43m        \u001B[49m\u001B[43mcookies\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mcookies\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m   1051\u001B[0m \u001B[43m        \u001B[49m\u001B[43mauth\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mauth\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m   1052\u001B[0m \u001B[43m        \u001B[49m\u001B[43mfollow_redirects\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mfollow_redirects\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m   1053\u001B[0m \u001B[43m        \u001B[49m\u001B[43mtimeout\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mtimeout\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m   1054\u001B[0m \u001B[43m        \u001B[49m\u001B[43mextensions\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mextensions\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m   1055\u001B[0m \u001B[43m    \u001B[49m\u001B[43m)\u001B[49m\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpx\\_client.py:821\u001B[0m, in \u001B[0;36mClient.request\u001B[1;34m(self, method, url, content, data, files, json, params, headers, cookies, auth, follow_redirects, timeout, extensions)\u001B[0m\n\u001B[0;32m    806\u001B[0m     warnings\u001B[38;5;241m.\u001B[39mwarn(message, \u001B[38;5;167;01mDeprecationWarning\u001B[39;00m)\n\u001B[0;32m    808\u001B[0m request \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mbuild_request(\n\u001B[0;32m    809\u001B[0m     method\u001B[38;5;241m=\u001B[39mmethod,\n\u001B[0;32m    810\u001B[0m     url\u001B[38;5;241m=\u001B[39murl,\n\u001B[1;32m   (...)\u001B[0m\n\u001B[0;32m    819\u001B[0m     extensions\u001B[38;5;241m=\u001B[39mextensions,\n\u001B[0;32m    820\u001B[0m )\n\u001B[1;32m--> 821\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43msend\u001B[49m\u001B[43m(\u001B[49m\u001B[43mrequest\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mauth\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mauth\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mfollow_redirects\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mfollow_redirects\u001B[49m\u001B[43m)\u001B[49m\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpx\\_client.py:908\u001B[0m, in \u001B[0;36mClient.send\u001B[1;34m(self, request, stream, auth, follow_redirects)\u001B[0m\n\u001B[0;32m    900\u001B[0m follow_redirects \u001B[38;5;241m=\u001B[39m (\n\u001B[0;32m    901\u001B[0m     \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mfollow_redirects\n\u001B[0;32m    902\u001B[0m     \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(follow_redirects, UseClientDefault)\n\u001B[0;32m    903\u001B[0m     \u001B[38;5;28;01melse\u001B[39;00m follow_redirects\n\u001B[0;32m    904\u001B[0m )\n\u001B[0;32m    906\u001B[0m auth \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_build_request_auth(request, auth)\n\u001B[1;32m--> 908\u001B[0m response \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_send_handling_auth\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m    909\u001B[0m \u001B[43m    \u001B[49m\u001B[43mrequest\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m    910\u001B[0m \u001B[43m    \u001B[49m\u001B[43mauth\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mauth\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m    911\u001B[0m \u001B[43m    \u001B[49m\u001B[43mfollow_redirects\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mfollow_redirects\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m    912\u001B[0m \u001B[43m    \u001B[49m\u001B[43mhistory\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43m[\u001B[49m\u001B[43m]\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m    913\u001B[0m \u001B[43m\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    914\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[0;32m    915\u001B[0m     \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m stream:\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpx\\_client.py:936\u001B[0m, in \u001B[0;36mClient._send_handling_auth\u001B[1;34m(self, request, auth, follow_redirects, history)\u001B[0m\n\u001B[0;32m    933\u001B[0m request \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mnext\u001B[39m(auth_flow)\n\u001B[0;32m    935\u001B[0m \u001B[38;5;28;01mwhile\u001B[39;00m \u001B[38;5;28;01mTrue\u001B[39;00m:\n\u001B[1;32m--> 936\u001B[0m     response \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_send_handling_redirects\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m    937\u001B[0m \u001B[43m        \u001B[49m\u001B[43mrequest\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m    938\u001B[0m \u001B[43m        \u001B[49m\u001B[43mfollow_redirects\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mfollow_redirects\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m    939\u001B[0m \u001B[43m        \u001B[49m\u001B[43mhistory\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mhistory\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m    940\u001B[0m \u001B[43m    \u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    941\u001B[0m     \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[0;32m    942\u001B[0m         \u001B[38;5;28;01mtry\u001B[39;00m:\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpx\\_client.py:973\u001B[0m, in \u001B[0;36mClient._send_handling_redirects\u001B[1;34m(self, request, follow_redirects, history)\u001B[0m\n\u001B[0;32m    970\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m hook \u001B[38;5;129;01min\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_event_hooks[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mrequest\u001B[39m\u001B[38;5;124m\"\u001B[39m]:\n\u001B[0;32m    971\u001B[0m     hook(request)\n\u001B[1;32m--> 973\u001B[0m response \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m_send_single_request\u001B[49m\u001B[43m(\u001B[49m\u001B[43mrequest\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    974\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[0;32m    975\u001B[0m     \u001B[38;5;28;01mfor\u001B[39;00m hook \u001B[38;5;129;01min\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_event_hooks[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mresponse\u001B[39m\u001B[38;5;124m\"\u001B[39m]:\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpx\\_client.py:1009\u001B[0m, in \u001B[0;36mClient._send_single_request\u001B[1;34m(self, request)\u001B[0m\n\u001B[0;32m   1004\u001B[0m     \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mRuntimeError\u001B[39;00m(\n\u001B[0;32m   1005\u001B[0m         \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mAttempted to send an async request with a sync Client instance.\u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m   1006\u001B[0m     )\n\u001B[0;32m   1008\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m request_context(request\u001B[38;5;241m=\u001B[39mrequest):\n\u001B[1;32m-> 1009\u001B[0m     response \u001B[38;5;241m=\u001B[39m \u001B[43mtransport\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mhandle_request\u001B[49m\u001B[43m(\u001B[49m\u001B[43mrequest\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m   1011\u001B[0m \u001B[38;5;28;01massert\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(response\u001B[38;5;241m.\u001B[39mstream, SyncByteStream)\n\u001B[0;32m   1013\u001B[0m response\u001B[38;5;241m.\u001B[39mrequest \u001B[38;5;241m=\u001B[39m request\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpx\\_transports\\default.py:218\u001B[0m, in \u001B[0;36mHTTPTransport.handle_request\u001B[1;34m(self, request)\u001B[0m\n\u001B[0;32m    205\u001B[0m req \u001B[38;5;241m=\u001B[39m httpcore\u001B[38;5;241m.\u001B[39mRequest(\n\u001B[0;32m    206\u001B[0m     method\u001B[38;5;241m=\u001B[39mrequest\u001B[38;5;241m.\u001B[39mmethod,\n\u001B[0;32m    207\u001B[0m     url\u001B[38;5;241m=\u001B[39mhttpcore\u001B[38;5;241m.\u001B[39mURL(\n\u001B[1;32m   (...)\u001B[0m\n\u001B[0;32m    215\u001B[0m     extensions\u001B[38;5;241m=\u001B[39mrequest\u001B[38;5;241m.\u001B[39mextensions,\n\u001B[0;32m    216\u001B[0m )\n\u001B[0;32m    217\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m map_httpcore_exceptions():\n\u001B[1;32m--> 218\u001B[0m     resp \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_pool\u001B[38;5;241m.\u001B[39mhandle_request(req)\n\u001B[0;32m    220\u001B[0m \u001B[38;5;28;01massert\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(resp\u001B[38;5;241m.\u001B[39mstream, typing\u001B[38;5;241m.\u001B[39mIterable)\n\u001B[0;32m    222\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m Response(\n\u001B[0;32m    223\u001B[0m     status_code\u001B[38;5;241m=\u001B[39mresp\u001B[38;5;241m.\u001B[39mstatus,\n\u001B[0;32m    224\u001B[0m     headers\u001B[38;5;241m=\u001B[39mresp\u001B[38;5;241m.\u001B[39mheaders,\n\u001B[0;32m    225\u001B[0m     stream\u001B[38;5;241m=\u001B[39mResponseStream(resp\u001B[38;5;241m.\u001B[39mstream),\n\u001B[0;32m    226\u001B[0m     extensions\u001B[38;5;241m=\u001B[39mresp\u001B[38;5;241m.\u001B[39mextensions,\n\u001B[0;32m    227\u001B[0m )\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\contextlib.py:131\u001B[0m, in \u001B[0;36m_GeneratorContextManager.__exit__\u001B[1;34m(self, type, value, traceback)\u001B[0m\n\u001B[0;32m    129\u001B[0m     value \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mtype\u001B[39m()\n\u001B[0;32m    130\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 131\u001B[0m     \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mgen\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mthrow\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;28;43mtype\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mvalue\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mtraceback\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m    132\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mStopIteration\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m exc:\n\u001B[0;32m    133\u001B[0m     \u001B[38;5;66;03m# Suppress StopIteration *unless* it's the same exception that\u001B[39;00m\n\u001B[0;32m    134\u001B[0m     \u001B[38;5;66;03m# was passed to throw().  This prevents a StopIteration\u001B[39;00m\n\u001B[0;32m    135\u001B[0m     \u001B[38;5;66;03m# raised inside the \"with\" statement from being suppressed.\u001B[39;00m\n\u001B[0;32m    136\u001B[0m     \u001B[38;5;28;01mreturn\u001B[39;00m exc \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m value\n",
      "File \u001B[1;32mC:\\mySpace\\mysoftware\\anaconda\\envs\\jue_jin\\lib\\site-packages\\httpx\\_transports\\default.py:77\u001B[0m, in \u001B[0;36mmap_httpcore_exceptions\u001B[1;34m()\u001B[0m\n\u001B[0;32m     74\u001B[0m     \u001B[38;5;28;01mraise\u001B[39;00m\n\u001B[0;32m     76\u001B[0m message \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mstr\u001B[39m(exc)\n\u001B[1;32m---> 77\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m mapped_exc(message) \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mexc\u001B[39;00m\n",
      "\u001B[1;31mConnectTimeout\u001B[0m: _ssl.c:1114: The handshake operation timed out"
     ]
    }
   ],
   "source": [
    "symbol = \"000980\"\n",
    "klines = client.k(symbol=symbol, begin=\"1991-01-01\", end=\"2023-02-20\")\n",
    "close_new =  klines['close'][-1]\n",
    "price_shareing_table = get_price_shareing_table_by_date_list_adj_price(client, symbol, klines['date'], '%Y-%m-%d', '%Y%m%d','qfq_factor')\n",
    "price_shareing_table = price_shareing_table.sort_values(by='fq_price', ascending=[False]).reset_index(drop=True)\n",
    "down_max_table = price_shareing_table[close_new>=price_shareing_table['fq_price']].sort_values('amounts',ascending=[False]).head(1)\n",
    "up_max_table = price_shareing_table[close_new<=price_shareing_table['fq_price']].sort_values('amounts',ascending=[False]).head(1)\n",
    "down_rate = (down_max_table['fq_price'] - close_new)/close_new *100\n",
    "up_rate = (up_max_table['fq_price'] - close_new)/close_new *100\n",
    "stat_df = pd.DataFrame([[close_new,float(up_max_table['fq_price']),float(up_max_table['amounts']), round(float(up_rate),2), float(down_max_table['fq_price']),float(down_max_table['amounts']), float(down_rate)]],columns=['最新收盘价','收盘价上方最强阻力位（收盘价上方成交金额最大的价格）','成交金额','到达最强阻力位所需涨幅','收盘价下方最强支撑位(收盘价下方成交金额最大的价格)','成交金额','到达最强支撑位所需跌幅'])\n",
    "stat_df\n",
    "# table"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "获取通达信版块数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "blocks = reader.block(symbol='block_zs', group=True)\n",
    "blocks"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "通过mootdx获取本地k线数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "# 读取日线数据\n",
    "klines = reader.daily(symbol='000606')\n",
    "klines"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "下载通达信专业财务数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "response = subprocess.getstatusoutput(\"mootdx affair -f all -o JSON -d C://mySpace//data//finance//stock//finance\")\n",
    "response"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "读取财务信息"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "from mootdx.quotes import Quotes\n",
    "\n",
    "client = Quotes.factory(market='std')\n",
    "finance_info = client.finance(symbol=\"600300\")\n",
    "finance_info"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "下载通达信k线数据\n",
    "无法下载历史数据，只能读取已下载的数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "cmd = \"mootdx bundle -s 000606 -a daily -o minute.csv\"\n",
    "response = subprocess.getstatusoutput(cmd)\n",
    "response"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "通过akshare获取某只股票某个周期的复权价格"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "start_date = '20190826'\n",
    "end_date = '20190912'\n",
    "stock_zh_a_hist_df = ak.stock_zh_a_hist(symbol='000606', period=\"daily\", start_date=start_date, end_date=end_date, adjust=\"hfq\")\n",
    "stock_zh_a_hist_df.to_csv()"
   ],
   "metadata": {
    "collapsed": false
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
